In computer science, a virtual machine (VM) is a portion of software that, when executed on appropriate hardware, creates an environment allowing the virtualization of an actual physical computer system. Each VM may function as a self-contained platform, running its own operating system (OS) and software applications (processes). Typically, a hypervisor manages allocation and virtualization of computer resources and performs context switching, as may be necessary, to cycle between various VMs.
A host machine (e.g., computer or server) is typically enabled to simultaneously run multiple VMs, where each VM may be used by a local or remote client. The host machine allocates a certain amount of the host's resources to each of the VMs. Each VM is then able to use the allocated resources to execute applications, including operating systems known as guest operating systems. The hypervisor virtualizes the underlying hardware of the host machine or emulates hardware devices, making the use of the VM transparent to the VM operating system or the remote client that uses the VM.
The hypervisor is also responsible for maintaining a global memory mapping for each VM that it manages. Virtual memory is a well-known technique used in most general-purpose operating systems, and almost all modern processors have hardware to support it. Virtual memory creates a uniform virtual address space presented to the applications and allows the operating system and hardware to handle the address translation between the virtual address space and the physical address space. This technique no only simplifies the programmer's work, but also adapts the execution environment to support large address spaces, process protection, file mapping, and swapping in modern computer systems.
When running a VM, the hypervisor creates a contiguous addressable memory space for the VM. This memory space has the same properties as the virtual address space presented to the applications by the guest operating system. This allows the hypervisor to run multiple VMs simultaneously while protecting the memory of each VM from being accessed by others. Therefore, from the view of the application running inside the VM, the hypervisor adds an extra level of address translation that maps the VM physical addresses to the host virtual address or host physical addresses (depending on the particular virtualization implementation).
The VM may request to change, add, or remove a memory mapping. However, updating the memory mappings by the hypervisor for a VM is an expensive and inefficient operation. In addition, the number of mappings allowed for a VM at any time is also limited, further constraining the resources of the virtualization system.